﻿@model planerka.DataAccess.ViewModels.pageAndPageCategoriesViewModel
@using planerka.Web.Helpers;
@{ ViewBag.Title = "Управление страницами сайта";}

@section HeadContent {

    <link href="@Url.Content("~/Content/jquery.treeview.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/fck/fckeditor.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.treeview.js")" type="text/javascript"></script>
    
    <script type="text/javascript" src="@Url.Content("~/Scripts/jquery.cookie.js")"></script>
    <script type="text/javascript">
        $(function () {
            $("#browser").treeview({
                collapsed: true,
                persist: "location"
            });

           
        })
    </script>
}


    <h2>Управление страницами сайта</h2>

    <div id="formWrapper">
        <div style="width:250px; float:left; margin-right: 5px; min-height: 500px;">
            <!-- Pages tree -->
               @{ 
                    int _selectedPage_ID = 0;
                    
                    if (Model.CurrentPage != null)
                    {
                        _selectedPage_ID = Model.CurrentPage.ID;
                    }
                    
                }

        @Html.Raw(Html.renderPagesAndPageCategories(_selectedPage_ID) )

            <!-- eof Pages tree -->
        </div>
        <div style="margin-left:250px">
        <span class="resultMessage">@Html.Raw(ViewData["resultMessage"] != null ? ("<span>" + ViewData["resultMessage"] + "</span>") : "")</span> 
        
            <!-- Page details -->
            @{ string adminDir = System.Configuration.ConfigurationManager.AppSettings["adminDirectory"]; }
        @using (Html.BeginForm("managePages", adminDir, FormMethod.Post,
                             new { enctype = "multipart/form-data" }))
           {
           
        <div id="editForm" style="margin-top: 0px" class="editForm">
            <fieldset>
                <div class="div150px">
                    <b><strong>
                        Дата:&nbsp;</strong></b>
                </div>
                <div class="div300px" style="text-align: left;">
                    <b><strong>
                   @Html.TextBox("date", Model.CurrentPage.date.ToShortDateString(),  new { style="width:150px;" })  </strong></b>
                    <span style="font-size: 8pt">
                    ДД.ММ.ГГГГ</span>
                </div>
                <div class="div150px">
                <!-- do not change buttons values! -->
                <input type="submit" value="Up" name="confirmButton" class="buttonsUpDown" />
                <input type="submit" value="Down" name="confirmButton" class="buttonsUpDown" />
                 
                </div>
            </fieldset>

            <fieldset>
                <div class="div150px">
                    Заголовок:&nbsp;
                </div>
                <div class="div300px">
                @Html.TextBox("header", Model.CurrentPage.header, new { style = "width: 440px;" })
                @Html.ValidationMessage("header")
        
                </div>

            </fieldset>

            <fieldset>
                    <div class="div150px">
                        Категория:&nbsp;
                    </div>
                    <div class="div150px">
                    @Html.DropDownList("pageCategoriesDD", new SelectList(ViewData["pageCategories"] as System.Collections.IEnumerable, "id", "pageCategoryRouteValue", Model.CurrentPage.category_ID.ToString()), new { style = "width: 140px;" })
                    </div>
                    
                    <div class="div50px">
                        ЧПУ:
                    </div>
                    <div class="div250px">
                    @Html.TextBox("URL", Model.CurrentPage.URL, new { style = "width: 240px;" })
                    <span style="font-size: 8px">
                    Если пустое, формируется автоматически</span>
                    </div>

                </fieldset> 

                <!-- META -->
           <fieldset>
                <div class="div150px">
                    meta-Title: &nbsp;
                    <img alt="question" src="@Url.Content("~/Content/images/question24.png")"   />
                </div>
                <div style="width: 450px; float: left;">
                 @Html.TextBox("metaTitle", Model.CurrentPage.metaTitle, new { style = "width: 440px;" })
                   <br />
                   <span style="font-size: 8px">
                        Если поле не заполнено, то для заполнения тэга используется название страницы
                    </span>
                </div>
            </fieldset>

             <fieldset>
                <div class="div150px">
                    meta-keywords:&nbsp;
                </div>
                <div style="width: 450px; float: left;">
                    @Html.TextArea("metaKeywords", Model.CurrentPage.metaKeywords, new { style = "width: 440px; height: 70px;" })
                </div>
            </fieldset>

            <fieldset>
                <div class="div150px">
                    meta-Description:&nbsp;
                </div>
                <div style="width: 450px; float: left;">
                @Html.TextArea("metaDescription", Model.CurrentPage.metaDescription, new { style = "width: 440px; height: 70px;" })
                     
                </div>
            </fieldset> 
            <!-- eof META -->

            <fieldset >
                <div class="div150px">
                    Анонс:&nbsp;
                </div>
                <div style="width: 450px; float: left;">
                @Html.TextArea("announce", Model.CurrentPage.HTML_announce, new { style = "width: 440px; height: 90px;" })
                       
                </div>
            </fieldset>
            
             <fieldset>
                <div class="div150px">
                    Содержание:&nbsp;
                </div>
                <div style=" float: left; width: 90%">  
        @Html.TextArea("HtmlContent", Model.CurrentPage.HTML_text, new { style = "width: 680px; " })
                </div>
             </fieldset>

        @Html.Hidden("id", Model.CurrentPage.ID)
        <p>
            <!-- do not change button values! -->
            <input type="submit" value="Сохранить страницу" name="confirmButton" />
            <input type="submit" value="Добавить страницу" name="confirmButton" />
            <input type="submit" value="Удалить страницу" name="confirmButton" />
        </p>
    </div>
    }         
    </div>
        <div class="clear">&nbsp;</div>
    </div>
    <div>
        @Html.ActionLink("Перейти в раздел управления категориями страниц", "ManagePageCategories")
    </div>

<script type="text/javascript">
    window.onload = function () {
        var sBasePath = '@Url.Content("~/Scripts/fck/")';
        var oFCKeditor = new FCKeditor('HtmlContent');
        oFCKeditor.Config.Enabled = true;
        oFCKeditor.Config.UserFilesPath = '/Content/UserContent';
        oFCKeditor.Config.UserFilesAbsolutePath = '/Content/UserContent';

        oFCKeditor.Height = '500';
        oFCKeditor.Width = '680';
        oFCKeditor.BasePath = sBasePath;
        oFCKeditor.ReplaceTextarea();
    }
</script>



